import '../../../lib_baseview/provider.dart';
import '../../../lib_runtime/logger.dart';
import 'root_proxy_model.dart';

abstract class ChatRoomChangeNotifier extends JRChangeNotifier {
  RootProxyModel _roomModel = RootProxyModel.instance!;
  RootProxyModel get roomModel => _roomModel;
  bool roomModelInited = false;

  set roomModel(RootProxyModel model) {
    if (roomModelInited && _roomModel == model) {
      RLog.d('RootModel already set, only notify change');
    } else {
      roomModelInited = true;
      _roomModel = model;
      // _roomModel.register(this);
      // Notify listeners, in case the new catalog provides information
      // different from the previous one. For example, availability of an item
      // might have changed.
      try {
        onRootProxyModelCreated();
      } catch (e) {
        RLog.d("onRootProxyModelCreated error:$e");
      }
    }

    notifyListeners();
  }

  onRootProxyModelCreated() {}

  @override
  void dispose() {
    release();
    super.dispose();
    if (roomModelInited) {
      // _roomModel.unregister(this);
    }
  }

  release() {}

  observeMessage(int messageId, dynamic data) {}
}
